<!DOCTYPE html>
<html lang="en">
<head>
    {% include "inc/common.html" %}
    <title>中搜API</title>
    <style>
        pre {
            padding: .5rem;
            min-height: 200px;
            border: 1px solid #ccc;
            border-radius: .2rem;
            box-sizing: border-box;
        }
        .string { color: green; }
        .number { color: darkorange; }
        .boolean { color: blue; }
        .null { color: magenta; }
        .key { color: red; }
    </style>
</head>
<body>
{% include "inc/header.html" %}

<div class="pure-form pure-form-aligned">
    <legend><h1>{{ title }}</h1></legend>
    <div class="pure-control-group">
        <label for="id_method">API</label>
        <select id="id_method">
            <optgroup label="1.商品API接口">
                <option value="biz.product.PageNum.query">查询商品池编号（biz.product.PageNum.query）</option>
                <option value="biz.product.sku.query">查询池内商品编号接口（biz.product.sku.query）</option>
                <option value="biz.product.detail.query">查询商品详细信息接口（biz.product.detail.query）</option>
                <option value="biz.product.state.query">查询商品上下架状态接口（biz.product.state.query）</option>
                <option value="biz.product.skuImage.query">查询所有图片信息接口（biz.product.skuImage.query）</option>
                <option value="biz.product.checkAreaLimit.query">查询商品区域购买限制接口（biz.product.checkAreaLimit.query）</option>
            </optgroup>
            <optgroup label="2.价格API接口">
                <option value="biz.price.sellPrice.get">批量查询价格（biz.price.sellPrice.get）</option>
            </optgroup>
            <optgroup label="3.地址API接口">
                <option value="biz.address.allProvinces.query">查询京东一级地址（biz.address.allProvinces.query）</option>
                <option value="biz.address.citysByProvinceId.query">查询京东二级地址（biz.address.citysByProvinceId.query）</option>
                <option value="biz.address.countysByCityId.query">查询京东三级地址（biz.address.countysByCityId.query）</option>
                <option value="biz.address.townsByCountyId.query">查询京东四级地址（biz.address.townsByCountyId.query）</option>
            </optgroup>
            <optgroup label="1.4.库存API接口">
                <option value="biz.stock.fororder.batget">1.4.1批量获取库存接口（biz.stock.fororder.batget）</option>
            </optgroup>
            <optgroup label="1.5.消息API接口">
                <option value="biz.message.get">1.5.1信息推送接口（biz.message.get）</option>
                <option value="biz.message.del">1.5.2删除推送信息接口（biz.message.del）</option>
            </optgroup>
            <optgroup label="2.2.下单环节API接口">
                <option value="biz.order.occupyStock.confirm">2.2.1确认预占库存订单接口（biz.order.occupyStock.confirm）</option>
                <option value="biz.order.occupyStock.confirm">2.2.2发起支付接口（biz.order.doPay）</option>
                <option value="biz.order.jdOrder.query">2.2.4查询京东订单信息接口（biz.order.jdOrder.query）</option>
                <option value="biz.order.jdOrderIDByThridOrderID.query">2.2.5订单反查接口（biz.order.jdOrderIDByThridOrderID.query）</option>
                <option value="biz.order.orderTrack.query">2.2.6查询配送信息信息接口（biz.order.orderTrack.query）</option>
            </optgroup>
            <optgroup label="2.4.查询余额API接口">
                <option value="biz.price.balance.get">统一余额查询API接口（biz.price.balance.get）</option>
            </optgroup>
            <optgroup label="3.售后API接口">
                <option value="biz.afterSale.availableNumberComp.query">3.3校验某订单中某商品是否可以提交售后服务（biz.afterSale.availableNumberComp.query）</option>
                <option value="biz.afterSale.customerExpectComp.query">3.4根据订单号、商品编号查询支持的服务类型（biz.afterSale.customerExpectComp.query）</option>
                <option value="biz.afterSale.wareReturnJdComp.query">3.5根据订单号、商品编号查询支持的商品返回京东方式（biz.afterSale.wareReturnJdComp.query）</option>
                <option value="biz.afterSale.serviceListPage.query">3.6根据客户账号和订单号分页查询服务单概要信息（biz.afterSale.serviceListPage.query）</option>
                <option value="biz.afterSale.serviceDetailInfo.query">3.7根据服务单号查询服务单明细信息（biz.afterSale.serviceDetailInfo.query）</option>
{#                <option value="biz.afterSale.auditCancel.query">3.8取消服务单/客户放弃（biz.afterSale.auditCancel.query）</option>#}
            </optgroup>
            <optgroup label="4.补充商品相关接口">
                <option value="jingdong.new.ware.baseproduct.get">4.3获取商品基本信息（jingdong.new.ware.baseproduct.get）</option>
                <option value="jingdong.ware.productbigfield.get">4.4获取商品大字段信息（jingdong.ware.productbigfield.get）</option>
                <option value="jingdong.new.ware.mobilebigfield.get">4.11移动商品介绍查询接口（jingdong.new.ware.mobilebigfield.get）</option>
            </optgroup>

        </select>
    </div>
    <div class="pure-control-group">
        <label for="id_param">Param</label>
        <textarea name="name_param" id="id_param" rows="10" class="pure-u-17-24"></textarea>
    </div>
    <div class="pure-control-group">
        <label for="id_send"></label>
        <button class="pure-button pure-button-primary" id="id_send">Send <i class="fa fa-mouse-pointer"></i></button>
    </div>
    <div class="pure-control-group">
        <label for="id_result">Result</label>
        <pre name="" id="id_result" class="pure-u-17-24"></pre>
    </div>
</div>


{% include "inc/footer.html" %}

<script>
    $('#id_send').click(function(){
        $.ajax({
            url : '{% url "exec_jd_api" %}',
            data : {
                m : $('#id_method').val(),
                p : $('#id_param').val()
            }
        }).done(function (data) {
            $('#id_result').html(syntaxHighlight(JSON.parse(data)));
        });
    });
    $('#id_method').change(function(){
        var m = $('#id_method').val();
        $('#id_param').val(paramLib[m] || '{\n\n}');
    });

    var paramLib = {
        'biz.product.PageNum.query'             : '{}',
        'biz.product.sku.query'                 : '{\n"pageNum":1\n}',
        'biz.product.detail.query'              : '{\n"sku":102194\n}',
        'biz.product.state.query'               : '{\n"sku":"868918,1741465"\n}',
        'biz.product.skuImage.query'            : '{\n"sku":"102194,1235325"\n}',
        'biz.product.checkAreaLimit.query'      : '{\n"skuIds":"1127453",\n"province":1,\n"city":2800,\n"county":2849,\n"Town":0\n}',

        'biz.price.sellPrice.get'               : '{\n"sku":"1546381,1433200"\n}',

        'biz.address.allProvinces.query'        : '{}',
        'biz.address.citysByProvinceId.query'   : '{\n"id":19\n}',
        'biz.address.countysByCityId.query'     : '{\n"id":1601\n}',
        'biz.address.townsByCountyId.query'     : '{\n"id":3634\n}',

        //1.4
        'biz.stock.fororder.batget'             : '{\n"skuNums":[\n{"skuId":1912292,"num":1},\n{"skuId":1912298,"num":1}\n],\n"area":"1_2800_2849_0"\n}',

        //1.5
        'biz.message.get'                       : '{\n"type":"1,2,4"\n}',
        'biz.message.del'                       : '{\n"id":114854711\n}',

        //2.2sw
        'biz.order.occupyStock.confirm'             : '{\n"jdOrderId":20222481058\n}',
        'biz.order.doPay'                           : '{\n"jdOrderId":20222481058\n}',
        'biz.order.jdOrder.query'                   : '{\n"jdOrderId":20222481058\n}',
        'biz.order.jdOrderIDByThridOrderID.query'   : '{\n"thirdOrder":160627223043895881\n}',
        'biz.order.orderTrack.query'                : '{\n"jdOrderId":20222481058\n}',

        //2.4
        'biz.price.balance.get'                     : '{\n"payType":4\n}',

        //3
        'biz.afterSale.availableNumberComp.query'   : '{\n"param":{\n"jdOrderId":20191406606,\n"skuId":800032\n}\n}',
        'biz.afterSale.customerExpectComp.query'    : '{\n"param":{\n"jdOrderId":20191406606,\n"skuId":800032\n}\n}',
        'biz.afterSale.wareReturnJdComp.query'      : '{\n"param":{\n"jdOrderId":20191406606,\n"skuId":800032\n}\n}',
        'biz.afterSale.serviceListPage.query'       : '{\n"param":{\n"jdOrderId":20191406606,\n"pageIndex":1,\n"pageSize":100\n}\n}',
        'biz.afterSale.serviceDetailInfo.query'     : '{\n"param":{\n"afsServiceId":232925903,\n"appendInfoSteps":[3,4]\n}\n}',
        'biz.afterSale.auditCancel.query'           : '{\n"param":{\n"serviceIdList":[11,12],\n"approveNotes":"审核意见"\n}\n}',

        //4
        'jingdong.new.ware.baseproduct.get'         : '{\n"skuIdSet":[1163750,2015877],\n"baseset":["name","url"]\n}',
        'jingdong.ware.productbigfield.get'         : '{\n"wid":"1163750",\n"fields":["wdis","wareQD","propCode","shouhou"]\n}',
        'jingdong.new.ware.mobilebigfield.get'      : '{\n"skuId":1163750\n}',



    };
    $('#id_method').change();


    function syntaxHighlight(json) {
        if (typeof json != 'string') {
            json = JSON.stringify(json, undefined, 4);
        }
        json = json.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
        return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, function(match) {
            var cls = 'number';
            if (/^"/.test(match)) {
                if (/:$/.test(match)) {
                    cls = 'key';
                } else {
                    cls = 'string';
                }
            } else if (/true|false/.test(match)) {
                cls = 'boolean';
            } else if (/null/.test(match)) {
                cls = 'null';
            }
            return '<span class="' + cls + '">' + match + '</span>';
        });
    }
</script>
</body>
</html>
